/*
 * This file is part of aKoustiK.

 * aKoustiK is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.

 * aKoustiK is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License
 * along with aKoustiK.  If not, see <http://www.gnu.org/licenses/>.
 */

#include <KFileWidget>
#include <KGlobal>
#include <KSharedConfig>
#include <KSharedConfigPtr>
#include <QtCore/QDebug>
#include <QtGui/QVBoxLayout>

#include <ui/filebrowser/filebrowser.h>

FileBrowser::FileBrowser(QWidget *parent) : QWidget(parent) {
    qDebug("FileBrowser: constructor invoked");
    fileWidget = new KFileWidget(KUrl(KGlobal::config()->group("FileBrowser").readEntry("location", QDir::homePath())), this);
    fileWidget->setMode(KFile::ExistingOnly);
    fileWidget->setOperationMode(KFileWidget::Opening);

    QVBoxLayout* layout = new QVBoxLayout(this);
    layout->addWidget(fileWidget);
}

FileBrowser::~FileBrowser() {
    qDebug("FileBrowser: destructor invoked");
    KGlobal::config()->group("FileBrowser").writeEntry("location", fileWidget->baseUrl().pathOrUrl());
}
